Commit 52aa362d authored by Adrian DC's avatar Adrian DC
Browse files

chore: implement #149: handle simulated settings for virtual tests

parent 6b0171e3
Loading
Loading
Loading
Loading
+15 −1
Changes for gitlabci_local/package/settings.py: 15 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@

# Standard libraries
from configparser import ConfigParser
from sys import stdout

# Components
from ..prints.colors import Colors
@@ -34,9 +35,16 @@ class Settings:
            if self.get('package', 'name') != name:
                raise ValueError('Missing settings files')
        except ValueError:
            self.__folder.mkdir(parents=True, exist_ok=True)
            self.__prepare()
            self.__reset(name)

    # Prepare
    def __prepare(self):

        # Prepare folder path
        if not Platform.IS_SIMULATED:
            self.__folder.mkdir(parents=True, exist_ok=True)

    # Reset
    def __reset(self, name):

@@ -48,6 +56,7 @@ class Settings:
    def __write(self):

        # Write initial settings
        if not Platform.IS_SIMULATED:
            with open(self.__path, 'w') as output:
                self.__settings.write(output)

@@ -84,7 +93,12 @@ class Settings:
               Colors.RESET))
        print(' ')

        # Settings simulated contents
        if Platform.IS_SIMULATED:
            self.__settings.write(stdout)

        # Settings file contents
        else:
            with open(self.__path, 'r') as data:
                print(data.read())
            Platform.flush()