def test_updating_js(self):
        user = "******"
        result = UserCodeRouter(
            user,
            "js",
            ["https://gist.githubusercontent.com/davidbegin/raw/beginfun.js"],
        ).route()
        assert UserCode.count() == 1

        UserCode.approve(user, "beginfun")
        user_code = UserCode.last()
        assert user_code["approved"] == True

        result = UserCodeRouter(
            user,
            "js",
            [
                "https://gist.githubusercontent.com/davidbegin/raw/234232342/beginfun.js"
            ],
        ).route()
        assert UserCode.count() == 1
        user_code = UserCode.last()
        assert user_code["user"] == "beginbotbot"
        assert user_code["approved"] == True
        assert (
            user_code["code_link"] ==
            "https://gist.githubusercontent.com/davidbegin/raw/234232342/beginfun.js"
        )
        assert user_code["code_type"] == "js"
Exemplo n.º 2
0
    def test_extracing_name_from_url(self):
        UserCode(
            user="******", code_link="https://gitlab.com/real_url/raw", code_type="js",
        ).save()

        last = UserCode.last()
        assert last["approved"] == False
        assert last["name"] == "eno"
        assert last["owners"] == []

        assert UserCode.owned_by("eno") == ["eno.js"]
    def test_submit_custom_js(self):
        user = "******"
        result = UserCodeRouter(
            user,
            "js",
            ["https://gist.githubusercontent.com/davidbegin/raw"],
        ).route()
        assert "Thanks for the custom JS @beginbotbot!" in result

        js_filepath = Path(__file__).parent.parent.parent.joinpath(
            "chat_thief/js/beginbotbot.js")
        assert js_filepath.exists()
        user_code = UserCode.last()
        assert user_code["user"] == "beginbotbot"
        assert (user_code["code_link"] ==
                "https://gist.githubusercontent.com/davidbegin/raw")
        assert user_code["code_type"] == "js"
Exemplo n.º 4
0
    def test_user_code(self):
        assert UserCode.count() == 0

        UserCode(
            user="******",
            code_link="https://gitlab.com/real_url/beginwidget.js",
            code_type="js",
            approved=True,
        ).save()

        last = UserCode.last()
        assert last["approved"] == True
        assert last["name"] == "beginwidget"
        assert last["owners"] == []

        assert UserCode.owned_by("eno") == ["beginwidget.js"]

        assert UserCode.find_owners("beginwidget") == [
            "eno",
        ]

        result = UserCode.purchase("begin", "beginwidget")
        assert UserCode.find_owners("beginwidget") == ["eno", "begin"]
        assert UserCode.owned_by("begin") == ["beginwidget.js"]