Пример #1
0
    def prechecks(guardian, platform):

        get_manifest = GetManifest()
        check_manifest = CheckManifest()
        log = PyGuardianLogger()
        try:
            if not os.path.isdir(constants.DATA_DIR):
                log.info("Creating data directory")
                os.makedirs(constants.MANIFEST_DIR)
            if not os.path.isdir(constants.MANIFEST_DIR):
                log.info("Creating manifest directory")
                os.makedirs(constants.MANIFEST_DIR)
            if not os.path.isdir(constants.JSON_DIR):
                log.info("Creating JSON directory")
                os.makedirs(constants.JSON_DIR)
            if not os.path.isdir(constants.CHARACTER_JSON_DIR):
                log.info("Creating Character JSON directory")
                os.makedirs(constants.CHARACTER_JSON_DIR)
            if not os.listdir(str(Path.home()) + "/.pyguardian/DDB-Files"):
                log.info("Manifest files not available, requesting...")
                get_manifest(check_manifest())

            uri = check_manifest()
            if uri is not None:
                get_manifest(uri)

        except OSError:
            log.error("Can't create directories!")
            raise CannotCreateStorageDirectories()

        InputValidator.validate(guardian, platform)

        return GuardianProcessor.process(guardian, platform)
Пример #2
0
    def test_guardian_processor_returns_processed_player_name(self):
        processed_results = GuardianProcessor.process("ernie#909090", "pc")

        self.assertEqual(processed_results[0], "ernie%23909090")
Пример #3
0
    def test_guardian_processor_returns_correct_with_whitespace_octothorpe_and_uppercase_input(
            self):
        processed_results = GuardianProcessor.process(" ernie#22462   ",
                                                      "     PLAYSTATION ")

        self.assertEqual(processed_results, ("ernie%2322462", "2"))
Пример #4
0
    def test_guardian_processor_returns_correct_platform_with_uppercase_input(
            self):
        processed_results = GuardianProcessor.process("ernie", "PLAYSTATION")

        self.assertEqual(processed_results[1], "2")
Пример #5
0
    def test_guardian_processor_returns_correct_platform_number_xbox(self):
        processed_results = GuardianProcessor.process("ernie", "xbox")

        self.assertEqual(processed_results[1], "1")
Пример #6
0
    def test_guardian_processor_returns_correct_platform_number_playstation(
            self):
        processed_results = GuardianProcessor.process("ernie", "playstation")

        self.assertEqual(processed_results[1], "2")
Пример #7
0
    def test_guardian_processor_returns_player_name_without_whitespace(self):
        processed_results = GuardianProcessor.process("   ernie  ", "pc     ")

        self.assertEqual(processed_results, ("ernie", "3"))