예제 #1
0
파일: api.py 프로젝트: jmduke/corji
class ApiTestCase(unittest.TestCase):

    def setUp(self):
        self.api = CorgiResource()

    def test_sanity(self):
        assert True

    def test_get_random(self):
        response = self.api.get()
        assert response is not None
        assert response["count"] is not None
        assert response["emoji"] is not None
        assert response["results"] is not None
        assert response["count"] == len(response["results"])
        assert response["count"] > 0

    def test_get_basic(self):
        response = self.api.get('🌈')
        assert response is not None
        assert response["count"] is not None
        assert response["emoji"] == '🌈'
        assert response["results"] is not None
        assert response["count"] == len(response["results"])
        assert response["count"] > 0

    def test_get_multiple_results(self):
        response = self.api.get('🐗')
        assert response is not None
        assert response["count"] > 1
        assert response["emoji"] == '🐗'
        assert len(response["results"]) > 1

    def test_get_non_emoji_input(self):
        response = self.api.get('ham sandwich')
        assert response is not None
        assert response["count"] == 0
        assert response["emoji"] == ''
        assert response["results"] == []

    def test_get_should_not_return_broken_links(self):
        response = self.api.get('🌿')
        assert response["count"] == 0
        assert response["emoji"] == '🌿'
        assert response["results"] == []

    def test_get_all(self):
        response = self.api.get_all()
        assert response is not None
        assert response["count"] > 10
        for result in response["results"]:
            assert result["emoji"] in response["emojis"]
            assert result["emoji_name"] is not None
            assert result["urls"] is not None
예제 #2
0
파일: send_batch.py 프로젝트: jmduke/corji
import random

from twilio.rest import TwilioRestClient

from corji.api import CorgiResource
from corji.data_sources import (
    google_spreadsheets
)
from corji.settings import Config

api = CorgiResource()
client = TwilioRestClient(Config.TWILIO_ACCOUNT_SID, Config.TWILIO_AUTH_TOKEN)

number_of_corgis_to_send = 2
corgis = []

while len(corgis) < number_of_corgis_to_send:
    random_emoji = random.choice(google_spreadsheets.keys())
    results = api.get(random_emoji)['results']
    if len(results):
        for result in results:
            if result not in corgis:
                corgis.append(result)

for corgi in corgis:
    message = client.messages.create(
        media_url=corgi,
        to="8046989478",
        from_=Config.TWILIO_PHONE_NUMBER
    )
예제 #3
0
파일: api.py 프로젝트: jmduke/corji
 def setUp(self):
     self.api = CorgiResource()