예제 #1
0
 def test_tag_no_value(self, tmp_path):
     char = Character(type=['human'])
     tmp_path.joinpath('U of Bros').mkdir()
     result = util.create_path_from_character(char,
                                              base_path=tmp_path,
                                              hierarchy='{school}')
     assert result == tmp_path
예제 #2
0
 def test_type_tag_value_substitution(self, tmp_path):
     char = Character(type=['human'])
     tmp_path.joinpath('Humans').mkdir()
     result = util.create_path_from_character(char,
                                              base_path=tmp_path,
                                              hierarchy='{type}')
     assert result == tmp_path.joinpath('Humans')
예제 #3
0
 def test_translated_presence_true(self, tmp_path):
     char = Character(type=['changeling'], motley=['Kickasso'])
     tmp_path.joinpath('Bros').mkdir()
     result = util.create_path_from_character(char,
                                              base_path=tmp_path,
                                              hierarchy='{type-unit?Bros}')
     assert result == tmp_path.joinpath('Bros')
예제 #4
0
 def test_literal_component(self, tmp_path):
     char = Character(type=['human'])
     tmp_path.joinpath('Dudes').mkdir()
     result = util.create_path_from_character(char,
                                              base_path=tmp_path,
                                              hierarchy='Dudes')
     assert result == tmp_path.joinpath('Dudes')
예제 #5
0
 def test_type_presence_true(self, tmp_path):
     char = Character(type=['human'])
     tmp_path.joinpath('Bros').mkdir()
     result = util.create_path_from_character(char,
                                              base_path=tmp_path,
                                              hierarchy='{type?Bros}')
     assert result == tmp_path.joinpath('Bros')
예제 #6
0
 def test_tag_presence_true_appends_path(self, tmp_path):
     char = Character(type=['human'], school=['U of Bros'])
     tmp_path.joinpath('Bros').mkdir()
     result = util.create_path_from_character(char,
                                              base_path=tmp_path,
                                              hierarchy='{school?Bros}')
     assert result == tmp_path.joinpath('Bros')
예제 #7
0
 def test_tag_presence_false_leaves_out_path(self, tmp_path):
     char = Character(type=['human'])
     tmp_path.joinpath('Bros').mkdir()
     result = util.create_path_from_character(char,
                                              base_path=tmp_path,
                                              hierarchy='{school?Bros}')
     assert result == tmp_path
예제 #8
0
 def test_configured_missing_value(self, tmp_path):
     char = Character(type=['changeling'])
     tmp_path.joinpath('Courtless').mkdir()
     result = util.create_path_from_character(char,
                                              base_path=tmp_path,
                                              hierarchy='{type-social}')
     assert result == tmp_path.joinpath('Courtless')
예제 #9
0
 def test_groups_and_ranks(self, tmpdir):
     char = npc.Character(type=['human'], group=['First', 'Second'], rank={'First': ['A', 'B']})
     tmpdir.mkdir('First')
     tmpdir.mkdir('First/Second')
     tmpdir.mkdir('First/A')
     result = util.create_path_from_character(char, base_path=str(tmpdir), hierarchy='{groups+ranks}')
     assert result == str(tmpdir.join('First').join('A'))
예제 #10
0
 def test_ranks_presence_true(self, tmp_path):
     char = Character(type=['human'],
                      ranks={'some frat': ['handstand guy']})
     tmp_path.joinpath('Bros').mkdir()
     result = util.create_path_from_character(char,
                                              base_path=tmp_path,
                                              hierarchy='{ranks?Bros}')
     assert result == tmp_path.joinpath('Bros')
예제 #11
0
 def test_wanderer_presence_true(self, tmp_path):
     """The foreign? check should include wanderer tag contents"""
     char = Character(type=['human'], wanderer=[''])
     char.tags('wanderer').touch()
     tmp_path.joinpath('Bros').mkdir()
     result = util.create_path_from_character(char,
                                              base_path=tmp_path,
                                              hierarchy='{foreign?Bros}')
     assert result == tmp_path.joinpath('Bros')
예제 #12
0
 def test_location_not_exist_and_foreign(self, tmp_path):
     # foreign is tried second
     char = Character(type=['human'],
                      foreign=['way the heck over there'],
                      location=['over here'])
     tmp_path.joinpath('way the heck over there').mkdir()
     result = util.create_path_from_character(char,
                                              base_path=tmp_path,
                                              hierarchy='{locations}')
     assert result == tmp_path.joinpath('way the heck over there')
예제 #13
0
 def test_group_folders(self, tmp_path):
     char = Character(type=['human'], group=['First', 'Second'])
     first = tmp_path / 'First'
     first.mkdir()
     second = first / 'Second'
     second.mkdir()
     result = util.create_path_from_character(char,
                                              base_path=tmp_path,
                                              hierarchy='{groups}')
     assert result == tmp_path.joinpath('First').joinpath('Second')
예제 #14
0
 def test_group_rank(self, tmp_path):
     char = Character(type=['human'], group=['First', 'Second'])
     char.tags('group').subtag('First').update(['A', 'B'])
     first = tmp_path / 'First'
     first.mkdir()
     first.joinpath('A').mkdir()
     first.joinpath('B').mkdir()
     result = util.create_path_from_character(char,
                                              base_path=tmp_path,
                                              hierarchy='{group}/{ranks}')
     assert result == tmp_path.joinpath('First').joinpath('A')
예제 #15
0
    def update_path(self):
        """Update the path label based on current values"""

        values = self.values.copy()

        tags = {}
        tags['type'] = values['ctype']
        if values['groups']:
            tags['group'] = values.pop('groups')

        tags.update({k: v for (k, v) in values.items() if v})

        temp_char = Character()
        temp_char.merge_all({**self.prefs.get('tag_defaults'), **tags})

        template_path = self.prefs.get('types.{}.sheet_template'.format(
            temp_char.type_key))
        char_name = values['name']
        if char_name:
            filename = char_name + path.splitext(template_path)[1]
        else:
            filename = ''
        base_path = create_path_from_character(temp_char, prefs=self.prefs)
        final_path = path.join(base_path, filename)

        path_exists = path.exists(final_path)

        if path_exists:
            self.buttonBox.button(
                QtWidgets.QDialogButtonBox.Ok).setEnabled(False)
        else:
            self.buttonBox.button(
                QtWidgets.QDialogButtonBox.Ok).setEnabled(True)

        if path_exists and char_name:
            self.path_dislpay.setText("Character already exists")
        else:
            self.path_dislpay.setText(final_path)
예제 #16
0
 def test_single_group(self, tmpdir):
     char = npc.Character(type=['human'], group=['First', 'Second'])
     tmpdir.mkdir('First')
     tmpdir.mkdir('First/Second')
     result = util.create_path_from_character(char, base_path=str(tmpdir), hierarchy='{group}')
     assert result == str(tmpdir.join('First'))
예제 #17
0
 def test_type_tag_value_substitution(self, tmpdir):
     char = npc.Character(type=['human'])
     tmpdir.mkdir('Humans')
     result = util.create_path_from_character(char, base_path=str(tmpdir), hierarchy='{type}')
     assert result == str(tmpdir.join('Humans'))
예제 #18
0
 def test_translated_tags(self, tmpdir):
     char = npc.Character(type=['changeling'], motley=['Kickasso'])
     tmpdir.mkdir('Kickasso')
     result = util.create_path_from_character(char, base_path=str(tmpdir), hierarchy='{type-unit}')
     assert result == str(tmpdir.join('Kickasso'))
예제 #19
0
 def test_ranks_presence_true(self, tmpdir):
     char = npc.Character(type=['human'], ranks={'some frat': ['handstand guy']})
     tmpdir.mkdir('Bros')
     result = util.create_path_from_character(char, base_path=str(tmpdir), hierarchy='{ranks?Bros}')
     assert result == str(tmpdir.join('Bros'))
예제 #20
0
 def test_tag_no_value(self, tmpdir):
     char = npc.Character(type=['human'], school=['U of Bros'])
     tmpdir.mkdir('U of Bros')
     result = util.create_path_from_character(char, base_path=str(tmpdir), hierarchy='{school}')
     assert result == str(tmpdir.join('U of Bros'))
예제 #21
0
 def test_type_presence_true(self, tmpdir):
     char = npc.Character(type=['human'])
     tmpdir.mkdir('Bros')
     result = util.create_path_from_character(char, base_path=str(tmpdir), hierarchy='{type?Bros}')
     assert result == str(tmpdir.join('Bros'))
예제 #22
0
 def test_wanderer_presence_true(self, tmpdir):
     """The foreign? check should include wanderer tag contents"""
     char = npc.Character(type=['human'], wanderer=[''])
     tmpdir.mkdir('Bros')
     result = util.create_path_from_character(char, base_path=str(tmpdir), hierarchy='{foreign?Bros}')
     assert result == str(tmpdir.join('Bros'))
예제 #23
0
 def test_configured_missing_value(self, tmpdir):
     char = npc.Character(type=['changeling'])
     tmpdir.mkdir('Courtless')
     result = util.create_path_from_character(char, base_path=str(tmpdir), hierarchy='{type-social}')
     assert result == str(tmpdir.join('Courtless'))
예제 #24
0
 def test_location_exists_with_foreign(self, tmpdir):
     # location is tried first
     char = npc.Character(type=['human'], foreign=['way the heck over there'], location=['over here'])
     tmpdir.mkdir('over here')
     result = util.create_path_from_character(char, base_path=str(tmpdir), hierarchy='{locations}')
     assert result == str(tmpdir.join('over here'))
예제 #25
0
 def test_literal_component(self, tmpdir):
     char = npc.Character(type=['human'])
     tmpdir.mkdir('Dudes')
     result = util.create_path_from_character(char, base_path=str(tmpdir), hierarchy='Dudes')
     assert result == str(tmpdir.join('Dudes'))