<commit_before>#!/usr/bin/python2.4
#
# Copyright (c) 2004-2005 rpath, Inc.
#

import testsuite
testsuite.setup()

import rephelp
from mint import userlevels

class ProjectTest(rephelp.RepositoryHelper):
    def testBasicAttributes(self):
        client = self.getMintClient("testuser", "testpass")
        projectId = client.newProject("Foo", "foo", "rpath.org")

        project = client.getProject(projectId)
        project.editProject("http://example.com/", "Description")

        project = client.getProject(projectId)
        assert(project.getFQDN() == "foo.rpath.org")
        assert(project.getHostname() == "foo")
        assert(project.getDomainname() == "rpath.org")
        assert(project.getName() == "Foo")
        assert(project.getDesc() == "Description")
        assert(project.getProjectUrl() == "http://example.com/")
        assert(project.getMembers() ==\
            [[2, 'testuser', userlevels.OWNER]])
    
    def testMembers(self):
        client = self.openMint(("test", "foo"))
        otherUserId = client.registerNewUser("member", "memberpass", "Test Member",
                        "<EMAIL>", "test at example.com", "", active=True)
 
        client = self.getMintClient("testuser", "testpass")
                                                       
        projectId = client.newProject("Foo", "foo", "localhost")
        project = client.getProject(projectId)

        project.addMemberById(otherUserId, userlevels.DEVELOPER)
                    
    def testLabels(self):
        client = self.getMintClient("testuser", "testpass")

        projectId = client.newProject("Foo", "foo", "rpath.org")
        project = client.getProject(projectId)
    
        assert(project.getRepoMap() ==\
            ["foo.rpath.org http://test:foo@localhost/repos/foo/"])
        assert(project.getLabelIdMap() ==\
            {"foo.rpath.org@rpl:devel": 1})
        
        newLabelId = project.addLabel("bar.rpath.org@rpl:devel",
            "http://rpath.org/repos/bar/", "user1", "<PASSWORD>")
        assert(project.getLabelById(newLabelId) == "bar.rpath.org@rpl:devel")

        assert(project.getRepoMap() ==\
            ['foo.rpath.org http://test:foo@localhost/repos/foo/',
             'bar.rpath.org http://user1:pass1@rpath.org/repos/bar/'])
        assert(project.getLabelIdMap() ==\
            {'bar.rpath.org@rpl:devel': newLabelId,
             'foo.rpath.org@rpl:devel': 1})
        
        project.editLabel(newLabelId, "bar.rpath.org@rpl:testbranch",
            "http://bar.rpath.org/conary/", "user1", "<PASSWORD>")
        assert(project.getLabelById(newLabelId) == "bar.rpath.org@rpl:testbranch")
                
        project.removeLabel(newLabelId)
        assert(project.getLabelIdMap() ==\
            {"foo.rpath.org@rpl:devel": 1})


if __name__ == "__main__":
    testsuite.main()
<commit_msg>fixed test case to work with ports<commit_after>#!/usr/bin/python2.4
#
# Copyright (c) 2004-2005 rpath, Inc.
#

import testsuite
testsuite.setup()

import rephelp
from mint import userlevels

class ProjectTest(rephelp.RepositoryHelper):
    def testBasicAttributes(self):
        client = self.getMintClient("testuser", "testpass")
        projectId = client.newProject("Foo", "foo", "rpath.org")

        project = client.getProject(projectId)
        project.editProject("http://example.com/", "Description")

        project = client.getProject(projectId)
        assert(project.getFQDN() == "foo.rpath.org")
        assert(project.getHostname() == "foo")
        assert(project.getDomainname() == "rpath.org")
        assert(project.getName() == "Foo")
        assert(project.getDesc() == "Description")
        assert(project.getProjectUrl() == "http://example.com/")
        assert(project.getMembers() ==\
            [[2, 'testuser', userlevels.OWNER]])
    
    def testMembers(self):
        client = self.openMint(("test", "foo"))
        otherUserId = client.registerNewUser("member", "memberpass", "Test Member",
                        "<EMAIL>", "test at example.com", "", active=True)
 
        client = self.getMintClient("testuser", "testpass")
                                                       
        projectId = client.newProject("Foo", "foo", "localhost")
        project = client.getProject(projectId)

        project.addMemberById(otherUserId, userlevels.DEVELOPER)
                    
    def testLabels(self):
        client = self.getMintClient("testuser", "testpass")

        projectId = client.newProject("Foo", "foo", "rpath.org")
        project = client.getProject(projectId)
    
        assert(project.getRepoMap() ==\
            ["foo.rpath.org http://test:foo@localhost:%i/repos/foo/" %self.getPort()])
        assert(project.getLabelIdMap() ==\
            {"foo.rpath.org@rpl:devel": 1})
        
        newLabelId = project.addLabel("bar.rpath.org@rpl:devel",
            "http://rpath.org/repos/bar/", "user1", "<PASSWORD>")
        assert(project.getLabelById(newLabelId) == "bar.rpath.org@rpl:devel")

        assert(project.getRepoMap() ==\
            ['foo.rpath.org http://test:foo@localhost:%i/repos/foo/' %self.getPort(),
             'bar.rpath.org http://user1:pass1@rpath.org/repos/bar/'])
        assert(project.getLabelIdMap() ==\
            {'bar.rpath.org@rpl:devel': newLabelId,
             'foo.rpath.org@rpl:devel': 1})
        
        project.editLabel(newLabelId, "bar.rpath.org@rpl:testbranch",
            "http://bar.rpath.org/conary/", "user1", "<PASSWORD>")
        assert(project.getLabelById(newLabelId) == "bar.rpath.org@rpl:testbranch")
                
        project.removeLabel(newLabelId)
        assert(project.getLabelIdMap() ==\
            {"foo.rpath.org@rpl:devel": 1})


if __name__ == "__main__":
    testsuite.main()

{'fraction_non_alphanumeric': 0.16085976772404229, 'fraction_numerical': 0.0062402496099844, 'mean_word_length': 2.533374157991427, 'pattern_counts': {'":': 6, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '192010', 'n_tokens_mistral': 1838, 'n_tokens_neox': 1771, 'n_words': 254}