def test_makeText():
    pub = Publishing()
    pub.user_id = "Superform"
    pub.post_id = "1"
    pub.date_from = '13.02.02'
    pub.title = 'test-Title'
    pub.link_url = 'blablablablablablablajdsfvjdbvjdnfvqebdnbqdfnvsdùnvbmqknkfnbùsfvdf'
    pub.description = 'descr'
    pub.image_url = 'image url'
    pub.date_until = '14.02.16'
    pub.state = 1
    pub.channel_id = 8

    text = wiki.makeText(pub, pub.user_id)
    tab_of_text = text.splitlines()
    date = str(datetime.datetime.now().strftime("%d/%m/%Y"))

    assert tab_of_text[0] == "!! " + pub.title
    assert tab_of_text[1] == "Par " + "Superform" + " Publié le " + date
    assert tab_of_text[2] == ""
    assert tab_of_text[
        3] == "-----"  #+str(pub.description).replace("\n","[[<<]]")
    assert tab_of_text[4] == str(pub.description).replace("\n", "[[<<]]")
    assert tab_of_text[5] == ""
    assert tab_of_text[6] == "-----" + "[[" + pub.link_url + "]]"
    assert tab_of_text[7] == "-----"
    assert tab_of_text[8] == pub.image_url
Beispiel #2
0
def test_uncorrect_config():
    pub = Publishing()
    pub.date_from = '13.02.02'
    pub.title = 'test-Title'
    pub.link_url = 'blablablablablablablajdsfvjdbvjdnfvqebdnbqdfnvsdùnvbmqknkfnbùsfvdf'
    pub.description = 'descr'
    pub.image_url = 'imague url'
    pub.date_until = '14.02.16'
    pub.state = 1
    pub.channel_id = 'Wiki'
    bad_json = json.dumps({"hello": ["coucou"]})

    answer = wiki.run(pub, bad_json)
    assert answer[0].value == StatusCode.ERROR.value
    assert answer[
        1] == "Error when getting the configuration"  # should not be "Couldn't connect to server"
def test_uncorrect_config():
    pub = Publishing()
    pub.date_from = '13.02.02'
    pub.title = 'test-Title'
    pub.link_url = 'blablablablablablablajdsfvjdbvjdnfvqebdnbqdfnvsdùnvbmqknkfnbùsfvdf'
    pub.description = 'descr'
    pub.image_url = 'imague url'
    pub.date_until = '14.02.16'
    pub.state = 1
    pub.channel_id = 'Wiki'
    bad_json = json.dumps({"hello": ["coucou"]})
    try:
        answer = wiki.run(pub, bad_json)
        assert answer == "error json decoder"
    except BaseException as e:
        #print(type(e))
        #print(e)
        # This could be a connection error, you need a live server to run this test successfully
        raise (e)
Beispiel #4
0
def test_send_tweet_correct_tweet():
    pub = Publishing()
    pub.date_from = '13.02.02'
    pub.link_url = ' : test string'
    rabdomStr = randomword(12)
    pub.description = "<tweet-separator>" + rabdomStr + "</tweet-separator> "
    pub.image_url = ""
    pub.date_until = '14.02.16'
    pub.state = 1
    pub.channel_id = 'Twitter'

    configdata = {'consumer_key': 'kTB8ji6trOpAXoQQBMgRwOUoz',
                  'consumer_secret': 'oJpKcyObcM6sakaStGsIJ0XnQceebPOrC5CcpJeD54jou1XAEm',
                  'access_token_key': '1052553285343858688-2KPjU0CKB5Y6HxR3G5FVUnC8bxZDTJ',
                  'access_token_secret': 'Sd8Se0oRuffyBwyRBmkgyJlaFVeE8HqQPcQm5rx08S9dx'}
    config = json.dumps(configdata)

    code = twitter.run(pub, config)
    assert code[0].value == StatusCode.OK.value
Beispiel #5
0
def test_run_uncorrect_credentials_JSON():
    pub = Publishing()
    pub.date_from = '13.02.02'
    pub.title = 'test-Title'
    pub.link_url = 'blablablablablablablajdsfvjdbvjdnfvqebdnbqdfnvsdùnvbmqknkfnbùsfvdf'
    pub.description = 'something something'
    pub.image_url = 'imague url'
    pub.date_until = '14.02.16'
    pub.state = 1
    pub.channel_id = 'Twitter'

    configdata = {"csumer_key": ["coucou"],
                  "consumer_seet": ["thisisfalse"],
                  "accesken_key": ["blabla"],
                  "acc_token_secret": ["beuh"]}
    config = json.dumps(configdata)
    code = twitter.run(pub, config)
    assert code[0].value == StatusCode.ERROR.value
    assert code[1] == "Uncorrect credentials, please review your configuration"
Beispiel #6
0
def test_run_with_empty_tweet():
    pub = Publishing()
    pub.date_from = '13.02.02'
    pub.title = 'test-Title'
    pub.link_url = 'blablablablablablablajdsfvjdbvjdnfvqebdnbqdfnvsdùnvbmqknkfnbùsfvdf'
    pub.description = ''
    pub.image_url = 'imague url'
    pub.date_until = '14.02.16'
    pub.state = 1
    pub.channel_id = 'Twitter'

    configdata = {"consumer_key": ["kTB8ji6trOpAXoQQBMgRwOUoz"],
                  "consumer_secret": ["oJpKcyObcM6sakaStGsIJ0XnQceebPOrC5CcpJeD54jou1XAEm"],
                  "access_token_key": ["1052553285343858688-2KPjU0CKB5Y6HxR3G5FVUnC8bxZDTJ"],
                  "access_token_secret": ["Sd8Se0oRuffyBwyRBmkgyJlaFVeE8HqQPcQm5rx08S9dx"]}
    config = json.dumps(configdata)
    code = twitter.run(pub, config)
    assert code[0].value == StatusCode.ERROR.value
    assert code[1] == "Empty tweet"
def test_run_false_credentials():
    pub = Publishing()
    pub.date_from = '13.02.02'
    pub.title = 'test-Title'
    pub.link_url = 'blablablablablablablajdsfvjdbvjdnfvqebdnbqdfnvsdùnvbmqknkfnbùsfvdf'
    pub.description = 'something something'
    pub.image_url = 'imague url'
    pub.date_until = '14.02.16'
    pub.state = 1
    pub.channel_id = 'Twitter'

    configdata = {
        "consumer_key": ["coucou"],
        "consumer_secret": ["thisisfalse"],
        "access_token_key": ["blabla"],
        "access_token_secret": ["beuh"]
    }
    config = json.dumps(configdata)
    result = twitter.run(pub, config)
    assert result == "uncorrect credentials"
def test_correct_wiki_post():
    config = {'username': ['superform'], 'password': ['superform']}
    pub = Publishing()
    pub.date_from = '13.02.02'
    pub.title = 'test-Title'
    pub.link_url = 'blablablablablablablajdsfvjdbvjdnfvqebdnbqdfnvsdùnvbmqknkfnbùsfvdf'
    pub.description = 'descr'
    pub.image_url = 'imague url'
    pub.date_until = '14.02.16'
    pub.state = 1
    pub.channel_id = 'Wiki'

    config_str = json.dumps(config)

    try:
        answer = wiki.run(pub, config_str)
        assert answer.status_code == 200
    except BaseException as e:
        #print(type(e))
        #print(e)
        # This could be a connection error, you need a live server to run this test successfully
        raise (e)
Beispiel #9
0
def test_correct_wiki_post():
    # verify that the server is on
    try:
        response = requests.post(wiki.urlwiki, None)
    except requests.exceptions.ConnectionError:
        assert False, "Can't connect to the pmwiki server."
    assert response.status_code == 200

    config = {'username': ['superform'], 'password': ['superform']}
    pub = Publishing()
    pub.date_from = '13.02.02'
    pub.title = 'test-Title'
    pub.link_url = 'blablablablablablablajdsfvjdbvjdnfvqebdnbqdfnvsdùnvbmqknkfnbùsfvdf'
    pub.description = 'descr'
    pub.image_url = 'imague url'
    pub.date_until = '14.02.16'
    pub.state = 1
    pub.channel_id = 'Wiki'

    config_str = json.dumps(config)

    answer = wiki.run(pub, config_str)
    assert answer[0].value == StatusCode.OK.value
    assert answer[1].status_code == 200