Exemplo n.º 1
0
 def test_saving_with_project(self):
     ud = UserData(target="target")
     ud.set_default(project="project-blah")
     ud.save()
     loaded = UserData.load()
     expect(hasattr(loaded, "project")).to_be_true()
     expect(loaded.project).to_equal("project-blah")
     expect(hasattr(loaded, "team")).to_be_false()
Exemplo n.º 2
0
 def test_saving_with_project(self):
     ud = UserData(target="target")
     ud.set_default(project="project-blah")
     ud.save()
     loaded = UserData.load()
     expect(hasattr(loaded, "project")).to_be_true()
     expect(loaded.project).to_equal("project-blah")
     expect(hasattr(loaded, "team")).to_be_false()
Exemplo n.º 3
0
    def test_user_data_returns_from_default_path(self):
        if exists(UserData.DEFAULT_PATH):
            os.remove(UserData.DEFAULT_PATH)

        ud = UserData(target="http://target3.wight.com")
        ud.save()

        loaded = UserData.load()
        expect(loaded).not_to_be_null()
        expect(loaded.target).to_equal("http://target3.wight.com")
Exemplo n.º 4
0
    def test_user_data_deserializes_properly(self):
        ud = UserData(target="http://target2.wight.com")

        directory = tempfile.mkdtemp()
        path = join(directory, '.wight-user-data')

        ud.save(path)

        loaded = UserData.load(path)
        expect(loaded.target).to_equal("http://target2.wight.com")
Exemplo n.º 5
0
    def test_user_data_returns_from_default_path(self):
        if exists(UserData.DEFAULT_PATH):
            os.remove(UserData.DEFAULT_PATH)

        ud = UserData(target="http://target3.wight.com")
        ud.save()

        loaded = UserData.load()
        expect(loaded).not_to_be_null()
        expect(loaded.target).to_equal("http://target3.wight.com")
Exemplo n.º 6
0
    def test_user_data_deserializes_properly(self):
        ud = UserData(target="http://target2.wight.com")

        directory = tempfile.mkdtemp()
        path = join(directory, '.wight-user-data')

        ud.save(path)

        loaded = UserData.load(path)
        expect(loaded.target).to_equal("http://target2.wight.com")
Exemplo n.º 7
0
    def test_user_data_serializes_properly(self):
        ud = UserData(target="http://target2.wight.com")

        directory = tempfile.mkdtemp()
        path = join(directory, '.wight-user-data')

        ud.save(path)

        with open(path, 'r') as text:
            obj = loads(text.read())
            expect(obj).to_include("target")
            expect(obj['target']).to_equal("http://target2.wight.com")
Exemplo n.º 8
0
    def test_user_data_serializes_properly(self):
        ud = UserData(target="http://target2.wight.com")

        directory = tempfile.mkdtemp()
        path = join(directory, '.wight-user-data')

        ud.save(path)

        with open(path, 'r') as text:
            obj = loads(text.read())
            expect(obj).to_include("target")
            expect(obj['target']).to_equal("http://target2.wight.com")
Exemplo n.º 9
0
    def default(self):
        self.load_conf()

        target = self.arguments.target
        self.line_break()
        self.putsuccess("Wight target set to '%s%s%s'. In order to login with wight, use '%swight login%s'." % (
            self.keyword_color, target, self.reset_success,
            self.commands_color, self.reset_success
        ))
        self.line_break()

        ud = UserData.load()
        if ud is None:
            ud = UserData(target=target)
        else:
            ud.target = target

        ud.save()
Exemplo n.º 10
0
    def default(self):
        self.load_conf()

        target = self.arguments.target
        target_parsed = urlparse(target)
        if not target_parsed.scheme:
            target = "http://%s" % target_parsed.geturl()

        self.line_break()
        self.putsuccess("Wight target set to '%s%s%s'. In order to login with wight, use '%swight login <email>%s'." % (
            self.keyword_color, target, self.reset_success,
            self.commands_color, self.reset_success
        ))
        self.line_break()

        ud = UserData.load()
        if ud is None:
            ud = UserData(target=target)
        else:
            ud.target = target

        ud.save()
Exemplo n.º 11
0
    def default(self):
        self.load_conf()

        target = self.arguments.target
        target_parsed = urlparse(target)
        if not target_parsed.scheme:
            target = "http://%s" % target_parsed.geturl()

        self.line_break()
        self.putsuccess(
            "Wight target set to '%s%s%s'. In order to login with wight, use '%swight login <email>%s'."
            % (self.keyword_color, target, self.reset_success,
               self.commands_color, self.reset_success))
        self.line_break()

        ud = UserData.load()
        if ud is None:
            ud = UserData(target=target)
        else:
            ud.target = target

        ud.save()