#metabrainz

/

      • LordSputnik
        We're using https://pythonhosted.org/Flask-Testing/ for testing flask endpoints
      • 2015-12-17 35152, 2015

      • LordSputnik
      • 2015-12-17 35106, 2015

      • stanislas
        ok, so should i use flask ?
      • 2015-12-17 35114, 2015

      • LordSputnik
        flask_testing.TestCase is derived from unittest.TestCase, I believe
      • 2015-12-17 35134, 2015

      • LordSputnik
        stanislas: so there shouldn't be any need to use flask.* stuff directly, just flask_testing
      • 2015-12-17 35128, 2015

      • LordSputnik
        (flask_testing gives you a "virtual client", with the ability to do stuff like self.client.get('/url/'))
      • 2015-12-17 35145, 2015

      • Leftmost
        Morning, fellas. (Though it's morning for neither of you.)
      • 2015-12-17 35159, 2015

      • stanislas
        Good evening Leftmost :)
      • 2015-12-17 35123, 2015

      • stanislas
        LordSputnik: And what entities should i use to test ?
      • 2015-12-17 35135, 2015

      • Leftmost
        Just took a look at Twitter and saw http://codexhackathon.com/. Dang, it would be cool to attend that.
      • 2015-12-17 35136, 2015

      • stanislas
        I've seen that test_relationship is using 3
      • 2015-12-17 35115, 2015

      • LordSputnik
        stanislas: For creator, you'll probably want to make an EditorType, an Editor, a Creator, an EntityRevision and a CreatorData
      • 2015-12-17 35141, 2015

      • LordSputnik
        That's for GET
      • 2015-12-17 35144, 2015

      • stanislas
        Ok, the question was really about if I should use real data ?
      • 2015-12-17 35153, 2015

      • LordSputnik
        For POST, you'll only need EditorType and Editor
      • 2015-12-17 35159, 2015

      • stanislas
        because it may change in a matter of time
      • 2015-12-17 35109, 2015

      • Leftmost
        No, we have testing data specifically for the unit tests.
      • 2015-12-17 35133, 2015

      • stanislas
        And how can I access this data?
      • 2015-12-17 35135, 2015

      • LordSputnik
        stanislas: no, you'll need to instantiate instances of those classes (either in setUp or in the test itself), then save them to your local testing database
      • 2015-12-17 35159, 2015

      • Leftmost
        LordSputnik, doesn't the bootstrap stuff set up testing data already?
      • 2015-12-17 35105, 2015

      • LordSputnik
        The data is created as part of the test
      • 2015-12-17 35109, 2015

      • LordSputnik
        Leftmost: some of it
      • 2015-12-17 35139, 2015

      • LordSputnik
        Hmm
      • 2015-12-17 35150, 2015

      • LordSputnik
        Actually, yeah, you're right, most of the data should get made by bootstrap :)
      • 2015-12-17 35107, 2015

      • LordSputnik
        stanislas: you can assume that everything in https://github.com/bookbrainz/bookbrainz-schema/b… is already in the database
      • 2015-12-17 35107, 2015

      • stanislas
        And where is the data ? (how it is named)
      • 2015-12-17 35148, 2015

      • LordSputnik
        That file contains a function which is run after the database tables get created, but just before the tests are run
      • 2015-12-17 35159, 2015

      • LordSputnik
        It adds all the necessary testing data to the database
      • 2015-12-17 35158, 2015

      • stanislas
        That's the revison_jsons data ?
      • 2015-12-17 35151, 2015

      • LordSputnik
        Actually, scrap that, that's not quite right
      • 2015-12-17 35109, 2015

      • LordSputnik
        The data that gets loaded for tests is actually in https://github.com/bookbrainz/bookbrainz-ws/blob/…
      • 2015-12-17 35117, 2015

      • Leo_Verto joined the channel
      • 2015-12-17 35135, 2015

      • LordSputnik
        It's exactly the same idea (and I'm sure we could probably combine those two files)
      • 2015-12-17 35140, 2015

      • LordSputnik
        stanislas: do you know much about ORMs or SQLAlchemy?
      • 2015-12-17 35144, 2015

      • Leo_Verto
        Combine ALL the files!
      • 2015-12-17 35156, 2015

      • LordSputnik
        If you don't this isn't going to make sense right now, so we should start with that :)
      • 2015-12-17 35137, 2015

      • LordSputnik
        (or rather, I've got to go out now for a bit, so Leftmost can start with that :D)
      • 2015-12-17 35154, 2015

      • stanislas
        LordSputnik : What do you actually mean by "If you don't this" ?
      • 2015-12-17 35117, 2015

      • stanislas
        aah, ok
      • 2015-12-17 35145, 2015

      • stanislas
        LordSputnik: I have zero knowledge about ORMs and SQLAlchemy
      • 2015-12-17 35150, 2015

      • LordSputnik
        stanislas: if you don't know about ORMs or SQLAlchemy, you probably won't be able to understand what's going on in fixture.py
      • 2015-12-17 35102, 2015

      • stanislas
        I do understand what entities are added
      • 2015-12-17 35122, 2015

      • stanislas
        very intuitive naming
      • 2015-12-17 35128, 2015

      • LordSputnik
        stanislas: Try to find an article or wiki page on ORMs, and maybe the front page of http://www.sqlalchemy.org/
      • 2015-12-17 35150, 2015

      • LordSputnik
        Then Leftmost will hopefully be able to answer any questions you have (or me, if I'm back)
      • 2015-12-17 35102, 2015

      • Leo_Verto
        <3 SQLAlchemy
      • 2015-12-17 35103, 2015

      • LordSputnik
        Then we can take another look at the data loading stuff
      • 2015-12-17 35109, 2015

      • LordSputnik
        (or Leo_Verto) :)
      • 2015-12-17 35148, 2015

      • LordSputnik
        stanislas: I would suggest reading the Wikipedia article on ORMs, but unfortunately the Polish version is only 3 lines long :P
      • 2015-12-17 35158, 2015

      • LordSputnik runs off
      • 2015-12-17 35111, 2015

      • Leo_Verto
        Polish is compact language
      • 2015-12-17 35127, 2015

      • stanislas
        Leo_Verto: no, definetely no
      • 2015-12-17 35132, 2015

      • Leo_Verto
        :P
      • 2015-12-17 35118, 2015

      • stanislas
        LordSputnik: That is not a problem. I am already reading and writing more in english than in polish
      • 2015-12-17 35124, 2015

      • Leo_Verto
        Also wouldn't make a lot of sense to get used to translated terminology when all of the documentation and communication is in English
      • 2015-12-17 35146, 2015

      • opatel99
        Mineo
      • 2015-12-17 35100, 2015

      • yeeeargh joined the channel
      • 2015-12-17 35109, 2015

      • regagain joined the channel
      • 2015-12-17 35101, 2015

      • stanislas
        Leftmost, Leo_Verto, LordSputnik: Why is it entity2 = Publication() in /tests/fixture.py and not entity2 = Author() ?
      • 2015-12-17 35126, 2015

      • stanislas
        Natsuo Kirino is no publication
      • 2015-12-17 35107, 2015

      • Leftmost
        It'd be Creator(), but good catch.
      • 2015-12-17 35152, 2015

      • stanislas
        so it should be = entity2 = Creator() ?
      • 2015-12-17 35114, 2015

      • JonnyJD has quit
      • 2015-12-17 35130, 2015

      • Leftmost
        That would make more sense, yes.
      • 2015-12-17 35106, 2015

      • stanislas
        Leftmost: I am going to change it and include it in my commit.
      • 2015-12-17 35141, 2015

      • stanislas
        (PR)
      • 2015-12-17 35100, 2015

      • oliverl has quit
      • 2015-12-17 35108, 2015

      • shakorim has quit
      • 2015-12-17 35147, 2015

      • shakorim joined the channel
      • 2015-12-17 35140, 2015

      • opatel99
        Mineo: Ping pong
      • 2015-12-17 35157, 2015

      • stanislas
        Leftmost, Leo_Verto, LordSputnik: How could I include bbschema in my repo? - I must include it to test my tests. It looks like some BB module.
      • 2015-12-17 35118, 2015

      • Leftmost
        I'm not sure I understand the question. Are you just looking to install it to run tests?
      • 2015-12-17 35111, 2015

      • stanislas
        yes
      • 2015-12-17 35123, 2015

      • Leftmost
        The repo is at https://github.com/bookbrainz/bookbrainz-schema. The instructions aren't fully complete, so let me know if you run into problems.
      • 2015-12-17 35152, 2015

      • stanislas
        Leftmost: Ok, thanks
      • 2015-12-17 35109, 2015

      • askirom has quit
      • 2015-12-17 35109, 2015

      • shakorim has quit
      • 2015-12-17 35154, 2015

      • askirom joined the channel
      • 2015-12-17 35154, 2015

      • askirom has quit
      • 2015-12-17 35154, 2015

      • shakorim joined the channel
      • 2015-12-17 35154, 2015

      • shakorim has quit
      • 2015-12-17 35133, 2015

      • stanislas
        Leftmost: Looks that everything is ok.
      • 2015-12-17 35136, 2015

      • stanislas
        and .fixture ?
      • 2015-12-17 35148, 2015

      • stanislas
        Leftmost: and .fixture ?
      • 2015-12-17 35133, 2015

      • Leftmost
        What about it?
      • 2015-12-17 35132, 2015

      • Leftmost
        If you mean how to make sure it's installed, the . in front means it's local, so there's no need to install it.
      • 2015-12-17 35144, 2015

      • Leo_Verto has quit
      • 2015-12-17 35127, 2015

      • stanislas
        python returns
      • 2015-12-17 35127, 2015

      • stanislas
        returns : File "/home/stas/gci2015/bookbrainz-ws/tests/test_user.py", line 10
      • 2015-12-17 35127, 2015

      • stanislas
        import .fixture
      • 2015-12-17 35127, 2015

      • stanislas
        ValueError: Attempted relative import in non-package
      • 2015-12-17 35112, 2015

      • stanislas
        Leftmost: ^
      • 2015-12-17 35158, 2015

      • Leftmost
        Hmm. How are you attempting to run it?
      • 2015-12-17 35119, 2015

      • stanislas
        I am using PyCharm
      • 2015-12-17 35159, 2015

      • stanislas
        there is a button there called "Unittests in bookbrainz-ws"
      • 2015-12-17 35134, 2015

      • Leftmost
        Hmm. Can you try running `python test.py' from the root directory?
      • 2015-12-17 35139, 2015

      • stanislas
        Leftmost: tried it now and it says "no password supplied"
      • 2015-12-17 35155, 2015

      • stanislas
        I guess it solves my previous problem
      • 2015-12-17 35133, 2015

      • Leftmost
        Hmm. Can you give the full error?
      • 2015-12-17 35151, 2015

      • stanislas
        EEEEEEEEEEE
      • 2015-12-17 35153, 2015

      • stanislas
        ======================================================================
      • 2015-12-17 35155, 2015

      • stanislas
        ERROR: test_relationship_get_many (tests.test_relationship.TestRelationshipViews)
      • 2015-12-17 35157, 2015

      • stanislas
        ----------------------------------------------------------------------
      • 2015-12-17 35159, 2015

      • stanislas
        Traceback (most recent call last):
      • 2015-12-17 35101, 2015

      • stanislas
        File "/home/stas/gci2015/bookbrainz-ws/tests/test_relationship.py", line 15, in setUp
      • 2015-12-17 35103, 2015

      • stanislas
        db.engine.execute("DROP SCHEMA IF EXISTS bookbrainz CASCADE")
      • 2015-12-17 35105, 2015

      • stanislas
        File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1862, in execute
      • 2015-12-17 35107, 2015

      • stanislas
        connection = self.contextual_connect(close_with_result=True)
      • 2015-12-17 35109, 2015

      • stanislas
        File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1910, in contextual_connect
      • 2015-12-17 35111, 2015

      • stanislas
        self.pool.connect(),
      • 2015-12-17 35113, 2015

      • stanislas
        really sorry for that
      • 2015-12-17 35113, 2015

      • stanislas
        File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/pool.py", line 338, in connect
      • 2015-12-17 35115, 2015

      • stanislas
        return _ConnectionFairy._checkout(self)
      • 2015-12-17 35117, 2015

      • stanislas
        File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/pool.py", line 645, in _checkout
      • 2015-12-17 35119, 2015

      • stanislas
        fairy = _ConnectionRecord.checkout(pool)
      • 2015-12-17 35121, 2015

      • stanislas
        File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/pool.py", line 440, in checkout
      • 2015-12-17 35123, 2015

      • stanislas
        rec = pool._do_get()
      • 2015-12-17 35112, 2015

      • Leftmost
        For future reference, please use a service like http://pastie.org/ or http://fpaste.org/ for anything longer than a couple lines.
      • 2015-12-17 35132, 2015

      • Leftmost
        You may need to use one anyhow, as the error was eventually cut off.
      • 2015-12-17 35113, 2015

      • stanislas
        Leftmost: I shutted down my IRC for a while. I didn't know how send file would work. Really sorry.
      • 2015-12-17 35110, 2015

      • Leftmost
        No problem. We all had to learn sometime. :)
      • 2015-12-17 35127, 2015

      • stanislas
      • 2015-12-17 35156, 2015

      • CatmanIX joined the channel
      • 2015-12-17 35155, 2015

      • Leftmost
        You likely need to edit line 2 of config/test.py to reflect a user in your database. I can walk you through setting one up if you need.
      • 2015-12-17 35132, 2015

      • stanislas
        I would be happy if you do that.
      • 2015-12-17 35104, 2015

      • Leftmost
        Do you know where to find your pg_hba.conf file? (If not, which distro are you running?)
      • 2015-12-17 35157, 2015

      • stanislas
        Leftmost: btw. Do i have to run some local bb server when testing?
      • 2015-12-17 35105, 2015

      • stanislas
        Leftmost: debian
      • 2015-12-17 35111, 2015

      • stanislas
        Leftmost: debian 8
      • 2015-12-17 35150, 2015

      • The_Catman has quit
      • 2015-12-17 35159, 2015

      • Leftmost
        -ws will run anything it needs to for you. You just need to have postgresql running.
      • 2015-12-17 35115, 2015

      • Leftmost
        Hmm. Check /var/lib for a directory called either pgsql or postgres or something of that ilk.
      • 2015-12-17 35101, 2015

      • stanislas
        Ok, i see where it is
      • 2015-12-17 35100, 2015

      • CallerNo6
        legoktm, the wiki logos should be good-to-go whenever you are in mb-wiki mode and looking for something to do.
      • 2015-12-17 35122, 2015

      • Leftmost
        Okay. So add a line that says `host sameuser bookbrainz 127.0.0.1/32 md5' to pg_hba.conf before the first line beginning with `host'.
      • 2015-12-17 35120, 2015

      • legoktm
        CallerNo6: awesome, I'll do that today evening
      • 2015-12-17 35150, 2015

      • Leftmost
        Then open up the psql commandline and run `CREATE USER bookbrainz WITH PASSWORD 'bookbrainz';'
      • 2015-12-17 35126, 2015

      • stanislas
        It says something like "role stas doesn't exist " (stas = my user name)
      • 2015-12-17 35127, 2015

      • Leftmost
        Oh, right. You have to run it as the postgres user. Run `sudo -i -u postgres' before running psql.
      • 2015-12-17 35113, 2015

      • chirlu`
        CallerNo6: Was this a task with one instance only?
      • 2015-12-17 35120, 2015

      • stanislas
        Leftmost: ok, done
      • 2015-12-17 35136, 2015

      • Leftmost
        Alright. You'll need to restart postgresql for the auth changes in pg_hba.conf to take effect, but once you've done that, try changing line 2 of config/test.py to read 'postgresql://bookbrainz:bookbrainz@localhost/bookbrainz_test'.
      • 2015-12-17 35131, 2015

      • opatel99
        Leftmost: looks like I just missed all the fun. I already organized all this into a file the day after we had it. Perhaps I could PR it as the INSTALL.md??
      • 2015-12-17 35155, 2015

      • Leftmost
        Maybe add it to the README.md under Setup and Testing headings.
      • 2015-12-17 35144, 2015

      • opatel99
        Leftmost: Cool. I will clean it up and tag all the code
      • 2015-12-17 35103, 2015

      • Leftmost
        Great, thank you. :)
      • 2015-12-17 35154, 2015

      • stanislas
      • 2015-12-17 35128, 2015

      • Leftmost
        Okay, that's just bizarre.
      • 2015-12-17 35129, 2015

      • Leftmost
        What does `psql -V' say?
      • 2015-12-17 35159, 2015

      • stanislas
        psql (PostgreSQL) 9.4.5